package tech.yunland.shop.domain.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.yunland.shop.domain.dao.ShipUserDao;
import tech.yunland.weixin.interfaces.IUserShipServices;

import java.util.List;

/**
 * 当用户关注公众号时如何保存用户的信息
 */
@Service
public class UserShipServicesImpl implements IUserShipServices {

    @Autowired
    private ShipUserDao shipUserDao;

    /**
     *
     * @param eventKey   qrscene_asdfasdfasdfasdfasdf
     * @param openId
     * @return
     */
    @Override
    public Boolean savaShipUserToPlant(String eventKey, String openId,String oid) {
            if(eventKey.contains("qrscene_")){
                String organId = eventKey.replace("qrscene_","");
                shipUserDao.saveShipOrganToUser(organId,openId);

            }else{
                shipUserDao.saveShipOrganToUser(oid,openId);
            }



        return null;
    }

    @Override
    public Boolean breakShipUserToPlant(String eventKey, String openId, String oid) {
        Boolean flag = shipUserDao.breakShipUserToPlant(oid,openId);
        return flag;
    }

    @Override
    public List<String> getOpenIdsByOrganId(String organId) {
        List<String> openIds = shipUserDao.getOpenIdsByOrganId(organId);
        return openIds;
    }
}
